﻿using System;
using System.Collections.Generic;
using System.Text;
#region WaveEngineStuffs
using WaveEngine.Common;
using WaveEngine.Common.Graphics;
using WaveEngine.Common.Helpers;
using WaveEngine.Common.Input;
using WaveEngine.Common.IO;
using WaveEngine.Common.Math;
using WaveEngine.Common.Media;
using WaveEngine.Common.System;
using WaveEngine.Components;
using WaveEngine.Components.Animation;
using WaveEngine.Components.Cameras;
using WaveEngine.Components.Graphics2D;
using WaveEngine.Components.Particles;
using WaveEngine.Components.Resources;
using WaveEngine.Components.UI;
using WaveEngine.Framework;
using WaveEngine.Framework.Animation;
using WaveEngine.Framework.Graphics;
using WaveEngine.Framework.Managers;
using WaveEngine.Framework.Physics2D;
using WaveEngine.Framework.Services;
using WaveEngine.Framework.Sound;
using WaveEngine.Framework.UI;
using WaveEngine.Graphics;
using WaveEngine.Materials;
#endregion

namespace NetworkedGameProject
{
    public class Level1 : Scene
    {
        private NetworkManager Network;

        protected override void CreateScene()
        {
            RenderManager.BackgroundColor = Color.CornflowerBlue;
            Network = new NetworkManager();
            AddSceneBehavior(Network, SceneBehavior.Order.PreUpdate);
            
        }

        protected override void Draw(TimeSpan gameTime)
        {
            int count = 0;

            foreach (Player player in Network.Players)
            {
                if (player.Connection != null)
                {
                    if (player.Connection.Status == Lidgren.Network.NetConnectionStatus.Connected)
                    {
                        count++;
                        if (player.Exist() == false) player.Create("SomeName" + count);
                    }
                    else
                    {
                        if (player.Exist()) player.Destroy();
                    }
                }
            }
            
            base.Draw(gameTime);
        }
    }
}
